﻿using MediatR;
using Warehouse.API.Applcation.Command.InjureCommand;
using Warehouse.Infrstructre.Interface;

namespace Warehouse.API.Applcation.CommandHandlers.InjureCommandHandler
{
    public class InjureAuditCommandHandler : IRequestHandler<InjureAuditCommand, int>
    {
        IInProductRepository IpRep;

        public InjureAuditCommandHandler(IInProductRepository IpRep)
        {
            this.IpRep = IpRep;
        }

        public async Task<int> Handle(InjureAuditCommand request, CancellationToken cancellationToken)
        {
            var list = await IpRep.GetModelAsync(request.InProductId);
            list.AuditStart = request.AuditStart;
            list.AuditResult = request.AuditResult;
            return await IpRep.UpdateAsync(list);
        }

    }
}
